<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="__PUBLIC__/Erp/Index/css/pintuer.css">
<link rel="stylesheet" href="__PUBLIC__/Erp/Index/css/admin.css">
<script src="__PUBLIC__/Erp/Index/js/jquery.js"></script>
<script src="__PUBLIC__/Erp/Index/js/pintuer.js"></script>
<link rel="stylesheet" href="__PUBLIC__/bootstrop/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="__PUBLIC__/bootstrop/bootstrap.min.js"></script>
<script src="__ROOT__/vendor/ueditor/ueditor.config.js"></script>
<script src="__ROOT__/vendor/ueditor/ueditor.all.min.js"></script>
<script src="__ROOT__/vendor/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong><span class="icon-key"></span> 更新News</strong></div>
  <div class="body-content">
    <form class="form-x" action="">
      <div class="form-group">
        <div class="label">
          <label for="sitename">站点名称：</label>
        </div>
        <div class="field">
          <input type="text" id='website' class="input"   placeholder="" readonly='readonly' value='{$info.website}'/>
          <input type='hidden' value="{$info.id}" id="newsId"/>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label for="sitename">Meta title：</label>
        </div>
        <div class="field">
          <input type="text" id='seoTitle' class="input"  value="{$info.seotitle}"  placeholder="" />
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label for="sitename">Meta description：</label>
        </div>
        <div class="field">
          <input type="text" id='seoDescription' value="{$info.seodescription}" class="input"  placeholder=""/>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label for="sitename">Meta keywords：</label>
        </div>
        <div class="field">
           <input type="text" id='seoKeywords' class="input" /><button type="button" class="btn btn-primary btn-xs" onclick="add_reply()">添加</button>
        </div>
                  <div class="label">
          <label for="sitename"></label>
        </div>
        <div class="field">
            <div id='replay_list' class="col-sm-9"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label for="sitename">NEWS标题：</label>
        </div>
        <div class="field">
          <input type="text" id='title' class="input" value="{$info.title}"  placeholder=""/>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label for="sitename">界面链接：</label>
        </div>
        <div class="field">
          <input type="text" id='static_html' class="input"  value="{$info.static_html}" placeholder="如填写aboutsm  在网站中将会显示www.xxx.com/aboutsm.html"/>
        </div>
      </div>





            <div class="form-group">
        <div class="label">
          <label for="sitename">统计脚本1：</label>
        </div>
        <div class="field">
         <textarea class="input" placeholder="说明：非必填，请输入谷歌等统计信息脚本" id='js_one'>{$info.js_one}</textarea>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label for="sitename">统计脚本2：</label>
        </div>
        <div class="field">
         <textarea class="input" placeholder="说明：非必填，请输入谷歌等统计信息脚本" id='js_two'>{$info.js_two}</textarea>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label for="sitename">统计脚本3：</label>
        </div>
        <div class="field">
         <textarea class="input" placeholder="说明：非必填，请输入谷歌等统计信息脚本" id='js_three'>{$info.js_three}</textarea>
        </div>
      </div>






      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="button" onclick="homePageSeo()"> 更新Library</button>
        </div>
      </div>
    </form>
  </div>
</div>
</body></html>
<script type="text/javascript">
          Array.prototype.removeByIndex = function (index) {
              if (index > -1) {
                  this.splice(index, 1);
              }
          }
          var replay_list = {$key};
          show_replay_list()
          function add_reply() {
              var replay = $('#seoKeywords').val()
              if(!$.trim(replay)){
                  alert('keywords不能为空');
                  return;
              }
              replay_list.push({replay:replay})
              $('#seoKeywords').val('')
              show_replay_list()
          }

          function show_replay_list() {
              $('#remove').remove()
              show_replay = '<div id="remove" class="modelList">'
              for (var i = 0; i < replay_list.length; i++) {
                  show_replay += '<div  style="float:left">'
                  show_replay +=       '<span class="btn btn-info btn-xs" style="margin: 2px">'
                  show_replay +=              replay_list[i].replay
                  show_replay +=         '</span>'
                  show_replay +=     '<a href="javascript:void(0)">'
                  show_replay +=          '<span style="color: red;" onclick=remove_replay_id('+i+')>'
                  show_replay +=             '[-]'
                  show_replay +=          '</span>'
                  show_replay +=       '</a>'
                  show_replay += '</div>'
              }
              show_replay+= '</div>'
              $('#replay_list').append(show_replay)
          }
          function remove_replay_id(id) {
              replay_list.removeByIndex(id)
              show_replay_list()
          }

          function homePageSeo(){
              var newsid = $('#newsId').val()
              var website = $('#website').val()
              var seoTitle   = $('#seoTitle').val()
              var seoDescription = $('#seoDescription').val()
              var seoKeywords = replay_list
              var title   = $('#title').val()
              var static_html = $('#static_html').val()
              var js_one = $('#js_one').val()
              var js_two = $('#js_two').val()
              var js_three = $('#js_three').val()
              if($.trim(newsid) == ''){
                  alert('缺少ID');return;
              }
              if($.trim(website) == ''){
                  alert('站点名称不能为空');return;
              }
              if($.trim(seoTitle) == ''){
                  alert('SEO Title不能为空');return;
              }
              if($.trim(seoDescription) == ''){
                  alert('SEO Description 不能为空');return;
              }
              if($.trim(title) == ''){
                  alert('简介标题不能为空');return;
              }
              if($.trim(static_html) == ''){
                  alert('界面链接不能为空');return;
              }
              $.post("__CONTROLLER__/saveUpdateLibrary",{newsid:newsid,website:website,seotitle:seoTitle,seodescription:seoDescription,seokeywords:seoKeywords,title:title,static_html:static_html,js_one:js_one,js_two:js_two,js_three:js_three},function(v){
                  if(v.f){
                      alert(v.data);
                      location.href="__CONTROLLER__/LibraryList";
                  }else{
                      alert(v.data);
                      location.reload();
                  }
              },'json')
          }
</script>